import {
	defineStore
} from "pinia";
export const mapStore = defineStore("map", {
	state: () => ({
		overLayers: [],
		plottingList: [

			{
				"id": 1,
				"name": "测试1",
				"creatTime": "2023-11-25 22:57:23",
				"makers": [
					{
						"text": "1",
						"icon": "t-icon-a-110110renminfangkongzhongdianchengshi",
						"color": "red",
						"isFont": false,
						"position": [
							121.00290649414063,
							37.539263916015635
						],
						"id": "1700924029303D",
						"type": "point"
					},
					{
						"text": "2",
						"icon": "icon-a-110109zhongyaofanghumubiao",
						"color": "green",
						"isFont": true,
						"position": [
							121.20340698242188,
							37.49394531250001
						],
						"id": "1700924037749D",
						"type": "point"
					}
				]
			},
			{
				"id": "1704291152028F",
				"name": "111",
				"creatTime": "2024-01-03 22:12:32",
				"makers": [
					{
						"name": "进攻方向",
						"font_class": "icon-a-030303jingongfangxiang",
						"isFont": true,
						"id": "1704291379874P",
						"draw": "squadcombat",
						"position": [
							[
								120.95123291015626,
								37.4688720703125
							],
							[
								121.25885009765626,
								37.254638671875
							],
							[
								121.34948730468751,
								37.184600830078125
							]
						],
						"color": "red",
						"type": "plygon"
					},
					{
						"name": "当前任务线",
						"font_class": "icon-a-030317dangqianrenwuxian",
						"isFont": true,
						"id": "1704291399699P",
						"draw": "rwline",
						"position": [
							[
								121.21353149414064,
								37.4359130859375
							],
							[
								121.79580688476564,
								37.33154296875
							]
						],
						"color": "red",
						"type": "plygon"
					},
					{
						"name": "染毒（沾染、污染）地域",
						"font_class": "icon-a-030333randuzhanranwurandiyu",
						"isFont": true,
						"id": "1704291405289P",
						"type": "plygon",
						"draw": "biggatheringplace",
						"position": [
							[
								120.83724975585939,
								37.198333740234375
							],
							[
								121.16683959960939,
								37.1392822265625
							]
						],
						"color": "green"
					}
				]
			}

		],
		editPlottingId: "",
		makerUpdate: {}
	}),
	actions: {
		setOverLayers(e) {
			this.$patch((state) => {
				state.overLayers = e;
			});
		},
		setList(obj) {
			this.$patch((state) => {
				state.plottingList.push(obj);
			});
		},
		setEditList(id, arr) {
			this.$patch((state) => {
				const index = state.plottingList.findIndex(x => x.id === id);
				state.plottingList[index].makers = arr;
			});
		},
		deletePlotting(arr) {
			this.$patch((state) => {
				state.plottingList = state.plottingList.filter(x => !arr.includes(x.id))
			});
		},
		setEditPlottingId(id) {
			this.$patch((state) => {
				state.editPlottingId = id
			});
		},
		setMakerUpdate(obj) {
			this.$patch((state) => {
				state.makerUpdate = obj
			});
		}
	},
});